home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / programming / colpectius1 / gradient_circle.amos / gradient_circle.amosSourceCode
AMOS Source Code  |  1993-08-18  |  1KB  |  48 lines

  1. ' Gradient circle
  2. ' ~~~~~~~~~~~~~~~
  3. ' by Ben Wyatt, bwyatt@paston.co.uk
  4.  
  5. ' Draws a gradiently filled circle, like in Dpaint, only not as good ;-) 
  6.  
  7. Degree 
  8.  
  9. ' Ask some tricky questions
  10. Input "Radius     (8-100) :";R : R=Min(Max(R,8),100)
  11. Input "Ditherness (0-  5) :";D : D=Min(Max(D,0),5)
  12. Flash Off : Curs Off : Cls 0
  13.  
  14. ' Create a spread of yellow
  15. For N=0 To 15
  16.    Colour N,N*256+N*16
  17. Next N
  18.  
  19. _GRADC[159,99,R,1,15,D]
  20.  
  21. Wait Key : Edit 
  22.  
  23. Procedure _GRADC[X,Y,R,SCOL,ECOL,DITH]
  24.  
  25.    ' Draws a gradiently filled circle with a centre X,Y and radius R
  26.    ' The colours used range between SCOL and ECOL 
  27.    ' DITH=Amount of Ditherness (0->size of range) 
  28.  
  29.    ' Get the range
  30.    RA=ECOL-SCOL-DITH
  31.  
  32.    For XT=X-R To X+R
  33.       For YT=Y-R To Y+R
  34.          ' Work out the distance from the centre
  35.          DIST=Sqr((XT-X)*(XT-X)+(YT-Y)*(YT-Y))
  36.          If DIST<=R
  37.             ' Work out the colour and add a bit of randomness to it (DITH) 
  38.             C=RA-(DIST*RA)/R
  39.             If DITH>0
  40.                RN=Rnd(DITH)
  41.                If RN=DITH : Add RN,-Rnd(1) : End If 
  42.             End If 
  43.              Extension_12_036E XT,YT,C+SCOL+RN
  44.          End If 
  45.       Next YT
  46.    Next XT
  47.  
  48. End Proc